package com.c1202m.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import javax.swing.JButton;
import javax.swing.JPanel;
import org.jdesktop.swingx.JXCollapsiblePane;
import org.netbeans.lib.awtextra.AbsoluteConstraints;
import org.netbeans.lib.awtextra.AbsoluteLayout;

public class TaiKhoanController extends JPanel {

    private JXCollapsiblePane collapsiblePane; //swingX
    private JButton collapsingButton; // for toogle panels

    public TaiKhoanController() {
        creat();
        bind();
    }

    private void creat() {
        setLayout(new BorderLayout());
        collapsiblePane = new JXCollapsiblePane();
        collapsiblePane.setAnimated(true);
        collapsiblePane.setCollapsed(true);
        add(collapsiblePane, BorderLayout.NORTH);
        collapsiblePane.setLayout(new AbsoluteLayout());
        BangTaiKhoan bangTaiKhoan = new BangTaiKhoan();
        BangGiaoDich danhSachTK = new BangGiaoDich();
        add(bangTaiKhoan, BorderLayout.CENTER);
        collapsiblePane.add(danhSachTK, new AbsoluteConstraints(0, 0, 760, 430));
        JPanel buttonPanel = new JPanel();
        buttonPanel.setBackground(Color.WHITE);
        add(buttonPanel, BorderLayout.SOUTH);
        collapsingButton = new JButton();
        collapsingButton.setText("» Tài khoản / Giao dịch «");
        collapsingButton.setForeground(Color.BLUE);
        collapsingButton.setContentAreaFilled(false);
        collapsingButton.setFocusable(false);
        collapsingButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        buttonPanel.add(collapsingButton);
    }

    private void bind() {
        collapsingButton.addActionListener(collapsiblePane.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION));
    }
}
